package com.eaoa.uc.busorder.action;

import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.lang.StringUtils;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.eaoa.base.EABaseAction;
import com.eaoa.uc.bustransfer.bo.BusTransferAddOrdersBO;
import com.stony.core.util.CoreUtils;

public class BusOrderNewTransferAction extends EABaseAction{

	protected ActionForward doWork(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		String ordernos = request.getParameter("ordernos");
		try {
			if(StringUtils.isNotBlank(ordernos)){
				List ordernoList = new ArrayList();
				String[] ordernoes = ordernos.split(",");
				for(int i=0; i<ordernoes.length; i++){
					Long orderno = CoreUtils.parseLong(ordernoes[i]);
					if(orderno!=null){
						ordernoList.add(orderno);
					}
				}
				new BusTransferAddOrdersBO(ordernoList).execute();
			}else{
				return mapping.getInputForward();
			}
		} catch (RuntimeException e) {
			return mapping.getInputForward();
		}
		
		
		return mapping.findForward("success");
	}
}
